﻿using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace Inovout.Web.Controllers
{
    public class ControllerFactory : DefaultControllerFactory
    {
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            ArgumentAssert.IsNotNull(controllerType, "controller");
            return ComponentRegistry.Resolve<IController>(controllerType);
        }
        //public override IController CreateController(RequestContext requestContext, string controllerName)
        //{
        //    string controllerComponentName = controllerName + "Controller";
        //    return ComponentRegistry.Resolve<IController>(controllerComponentName);
        //}

        public override void ReleaseController(IController controller)
        {
            ComponentRegistry.Release(controller);
        }
    }

}
